<?php
$this->breadcrumbs = array(
    TaskType::$names[$model->task_type] =>  array('index', 'type'=>$model->task_type),
    '任务详情',
);
?>

<?php $this->widget('bootstrap.widgets.TbDetailView', array( 
    'type'=>'striped bordered condensed',
    'data'=>$model, 
    'attributes'=>array( 
        'task_id',
        'job.job_name',
        'date', 
        array(
            'name' => 'task_type',
            'value' => TaskType::$names[$model->task_type],
        ),
        array(
            'name' => 'frequency',
            'value' => Frequency::$names[$model->frequency],
        ),
        array(
            'name' => 'priority',
            'value' => Priority::$labels[$model->priority],
        ),
        'executor_machine.hostname',
        'start_time',
        'end_time',
        array(
            'name' => 'state',
            'value' => TaskState::$names[$model->state],
        ),
        'detail',
        array(
            'name' => 'runtime_info',
            'type' => 'raw',
            'value' => $model->formatRuntimeInfo($model->runtime_info),
        ),
        array(
            'label' => '控制命令',
            'type' => 'raw',
            'value' => $model->getControlLink($model),
        ),
        array(
            'label' => '结果信息',
            'type' => 'raw',
            'visible' =>  $model->state == TaskState::Done,
            'value' => CHtml::linkButton('查看结果', array( 'submit'=>array('resource/index','id'=>$model->task_id, 'type'=>$model->task_type == TaskType::Query ? ResourceType::QueryOutput : ResourceType::ComputeOutput))),
        ),

    ), 
) 
); ?> 

<legend><small>命令列表</small></legend>
<?php $this->widget('bootstrap.widgets.TbGridView', array(
    'type'=>'striped bordered condensed',
    'dataProvider'  =>  $model->getCommands($model->task_id),
    'pager'=>array(
        'class'=>'CLinkPager',           
        'nextPageLabel'=>'下一页',           
        'prevPageLabel'=>'上一页',           
        'header'=>'',   
    ), 
    'summaryText'   =>  '',
    'columns'       =>  array(
       array(
            'header' => '#',
            'name'  =>  'cmd_id',
            'value' =>  '$data->cmd_id'
        ), 
        array(
            'name'  =>  'cmd_type',
            'value' =>  'CommandType::$names[$data->cmd_type]',
        ),
        array(
            'header'=>  '提交者',
            'name'  =>  'user_id',
            'value' =>  '$data->user->user_name',
        ),
        array(
            'name'  =>  'submit_time',
            'value' =>  '$data->submit_time'
        ), 
        array(
            'name'  =>  'accept_time',
            'value' =>  '$data->accept_time'
        ), 
        array(
            'name'  =>  'state',
            'value' =>  'CmdState::$names[$data->state]',
        ),
        array(
            'name'  =>  'detail',
            'value' =>  '$data->detail',
        ),
    ),
));
?>
